home *** CD-ROM | disk | FTP | other *** search
- #----------------------------------------------------------------------------------------------------------------------------------------------------
- # LtoU
- # MPW Shell Script
- # Written by Gina Cherry • August 16, 1991
- # Copyright: © 1991 by Apple Computer, Inc., all rights reserved.
- #
- # Usage:
- # LtoU [Window]
- #
- # Function:
- # LtoU converts the selected text in the specified window from lowercase to uppercase.
- #
- # Note: LtoU can be added to the Edit menu with the following command:
- # AddMenu Edit 'LtoU/4' 'LtoU "{Active}"'
- #----------------------------------------------------------------------------------------------------------------------------------------------------
-
- # Make sure there is no more than 1 parameter.
- If {#} > 1
- Echo "###Usage: {0} Window"
- Exit 1
- End
-
- # Do not exit on error.
- Set Exit 0
-
- #Initialize flag variable.
- Set flag ""
-
- # Set Window to the parameter, or to the target window if no parameter was given.
- If {#} == 1
- Set Window "{1}"
- Else
- Set Window "{Target}"
- End
-
- # Set the variable Old to the selected text in the input file. This command has the side effect of
- # checking whether
- # the window is open. Catenate will fail if Window is not an open window. The variable flag will be
- # set to 1 if and only if the Catenate command is not successful.
- Begin
- Set Old "`Catenate "{Window}.§" || Set flag 1 `"
- End ≥ Dev:Null
-
- # Check if flag variable is set; if it is, write error message and exit with status 2.
- If {flag}
- Echo "### {0}: {Window} not a valid window."
- Exit 2
- End
-
- # If no text was selected in the input window, exit script.
- Exit If "{Old}" == ""
-
- # Otherwise, do the conversion.
- # Save value of NewWindowRect to restore later.
- Set OldWindowRect "{NewWindowRect}"
-
- # Set NewWindowRect so that new windows are small.
- Set NewWindowRect 0,0,100,100
-
- # Open a temporary workspace.
- Open -n {0}.Temp
-
- # Restore value of NewWindowRect.
- Set NewWindowRect "{OldWindowRect}"
-
- # Translate all lowercase letters in the selected text to uppercase, and redirect the output to the
- # temporary file.
- Translate a-z A-Z < "{Window}.§" > {0}.Temp
-
- # Select the entire temporary file.
- Find •:∞ {0}.Temp
-
- # Copy the selected text to the clipboard.
- Copy § {0}.Temp
-
- # Write the converted text to Window, overwriting the old version of the text.
- Paste § "{Window}"
-
- # Close the workspace; don't save changes.
- Close -n {0}.Temp